package co.wizardattack.model;

import java.io.IOException;

import org.andengine.audio.music.Music;
import org.andengine.audio.music.MusicFactory;
import org.andengine.audio.music.MusicManager;
import org.andengine.audio.sound.Sound;
import org.andengine.audio.sound.SoundFactory;
import org.andengine.audio.sound.SoundManager;

import co.wizardattack.constants.ResourcesNames;

import android.content.Context;

public class Media {

	/**
	 * Constants
	 */
	private final int NUMBER_OF_EFFECTS = 1;
	private final int EFFECT_VOLCANO = 0;
	
	//private static final int NUMBER_OF_SONGS = 1;
	//public static final int SOUN_BATTLE = 0;
	/**
	 * Sounds
	 */
	private Music music;
	private Sound soundEffects[];
	private float volumeMusic = 0.2f;
	private float volumeEffect = 0.3f;

	public Media(SoundManager soundManager, MusicManager musicManager, Context context) throws IOException {
		// Loading music
		music = MusicFactory.createMusicFromAsset(musicManager, context, ResourcesNames.MUSIC_PATH);
		music.setLooping(true);
		music.setVolume(volumeMusic);
		// Loading effects
		soundEffects = new Sound[NUMBER_OF_EFFECTS];
		soundEffects[EFFECT_VOLCANO] = SoundFactory.createSoundFromAsset(soundManager, context, ResourcesNames.EFFECT_FIRE_PATH);
		soundEffects[EFFECT_VOLCANO].setLooping(false);
		soundEffects[EFFECT_VOLCANO].setVolume(volumeEffect);
	}
	
	public void playMusic() {
		this.music.play();
	}
	
	public void playEffect(int effectId) {
		soundEffects[effectId].play();
	}
	
	public int getEffectVolcano() {
		return EFFECT_VOLCANO;
	}
	
}
